package com.naza.rpc.consumer.balance;

import com.naza.rpc.model.LoadBalance;

/**
 * @author yl
 */
public abstract class LoadBalancerFactory {

    public static LoadBalancer getLoadBalancer(LoadBalance loadBalance) {
        if(null == loadBalance){
            return RoundRobinLoadBalancer.INSTANCE;
        }
        if (LoadBalance.Type.RANDOM.equals(loadBalance.getType())) {
            return RandomLoadBalancer.INSTANCE;
        } else if (LoadBalance.Type.ROUND_ROBIN.equals(loadBalance.getType())) {
            return RoundRobinLoadBalancer.INSTANCE;
        }
        //默认轮询
        return RoundRobinLoadBalancer.INSTANCE;
    }

}
